//
// Created by Martin on 2021/11/1.
//
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        set<int> s;
        int x;
        while (n-- > 0) {
            scanf("%d", &x);
            s.insert(x);
        }

        while (m-- > 0) {
            scanf("%d", &x);
            s.insert(x);
        }

        for (auto it = s.begin(); it != s.end(); ++it) {
            if (it != s.begin()) {
                printf(" ");
            }
            printf("%d", *it);
        }
        printf("\n");
    }
    return 0;
}
